<template>
	<view class="page">
		<view class="page__bd">
			<view class="scorelog-list">
				<view class="item" v-for="(item,index) in list">
					<view class="left">
						<view class="text">{{item.memo}}</view>
						<view class="date">{{item.createtime_text}}</view>
					</view>
					<view class="right">{{item.score}}</view>
				</view>
			</view>
			<!-- 空数据 -->
			<view class="u-u-p-t-80 u-m-t-80 u-p-b-80" v-if="!list.length">
				<u-empty src="/static/empty-log.png" text="什么也没有~" icon-size="375" mode="list"></u-empty>
			</view>
			<!-- 加载更多 -->
			<view class="u-p-b-30" v-if="list.length">
				<u-loadmore :status="has_more ? status : 'nomore'" />
			</view>
		</view>
		
		<u-back-top :scroll-top="scrollTop"></u-back-top>
	</view>
</template>
<script>
	export default {
		data() {
			return {
				list: [],
				page: 1,
				is_update: false,
				has_more: false,
				scrollTop: 0,
				status: 'loadmore'
			}
		},
		onLoad() {
			this.getMyScorelogList()
		},
		methods: {
			getMyScorelogList: async function() {
				this.$u.api.getScorelogList({
					page: this.page
				}).then(res => {
					uni.stopPullDownRefresh();
					if (res.code) {
						if (this.is_update) {
							this.list = [];
							this.is_update = false;
						}
						this.list = [...this.list, ...res.data.data];
						this.has_more = res.data.current_page < res.data.last_page;
					}
				});
			}
		},
		onPageScroll(e) {
			this.scrollTop = e.scrollTop;
		},
		//下拉刷新
		onPullDownRefresh() {
			this.is_update = true;
			this.page = 1;
			this.getMyScorelogList();
		},
		onReachBottom() {
			if (this.has_more) {
				this.status = 'loading';
				this.page++;
				this.getMyScorelogList();
			}
		}
	}
</script>

<style>
	.scorelog-list {
		padding: 50rpx;
	}

	.scorelog-list .item {
		display: flex;
		align-items: center;
		padding: 30rpx;
		border-bottom: 1rpx solid #eeeeee;
	}

	.scorelog-list .item .left {
		flex-grow: 1;
	}

	.scorelog-list .item .left .text {
		font-weight: bold;
		font-size: 32rpx;
		color: #2196F3;
	}

	.scorelog-list .item .left .date {
		font-size: 28rpx;
		color: #999999;
		margin-top: 10rpx;
	}

	.scorelog-list .item .right {
		color: #2196F3;
		font-size: 40rpx;
		font-weight: bold;

	}
</style>
